package com.yhyvr.pojo.resp.api.store.order;

import com.yhyvr.pojo.resp.api.store.address.ApiAddressInfoResp;
import com.yhyvr.pojo.resp.api.store.address.ApiOrderAddressResp;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by tech6 on 2016/10/20.
 */
public class ApiOrderInfoResp {
/*
    订单状态
            位数3位
    第一位为支付状态
0 未支付
1 已支付
2 已取消
3 已退货
            第二位为配送状态
0未发货
1 已发货
2 已收货
            第三位为订单锁定状态
0无状态
1 正在取消
2 退货（退款）确认中
3 备货中
*/

    private String  orderId;
    private String  orderState;
    private boolean  canFahuo;
    private boolean  canShouhuo;
    private boolean  canPay;
    private boolean  canDelete;
    private boolean  canCancel;
    private boolean  canComment;
    private boolean  canRefundGoods;
    private String   stateText;
    private String  orderNumber;
    private int  orderGoodsTotal;
    private String orderDiscountPrice;
    private String orderPrice;
    private String orderFreight;
    private String createTime;
    private String expressCompany;
    private String expressNumber;
    private ApiOrderAddressResp shippingAddress;
    private List<ApiOrderGoodsResp> orderGoodsList;

    public boolean isCanComment() {
        return canComment;
    }

    public void setCanComment(boolean canComment) {
        this.canComment = canComment;
    }

    public int getOrderGoodsTotal() {
        return orderGoodsTotal;
    }

    public void setOrderGoodsTotal(int orderGoodsTotal) {
        this.orderGoodsTotal = orderGoodsTotal;
    }

    public String getOrderDiscountPrice() {
        return orderDiscountPrice;
    }

    public void setOrderDiscountPrice(String orderDiscountPrice) {
        this.orderDiscountPrice = orderDiscountPrice;
    }

    public boolean isCanShouhuo() {
        String state="110,100";
        return state.indexOf(orderState)!=-1;
    }


    public boolean isCanFahuo() {
        String state="100";
        return state.indexOf(orderState)!=-1;
    }

    public boolean isCanPay() {
        String state="000";
        return state.indexOf(orderState)!=-1;
    }


    public boolean isCanDelete() {
        String state="200,";
        return state.indexOf(orderState)!=-1;
    }

    public boolean isCanCancel() {
        String state="100,000";
        return state.indexOf(orderState)!=-1;
    }


    public boolean isCanRefundGoods() {
        String state="110";
        return state.indexOf(orderState)!=-1;
    }

    public String getStateText() {
       switch (orderState){
           case "000":
               return "等待买家付款";
           case "100":
               return "等待卖家确认发货";
           case "104":
               return "卖家处理订单中";
           case "110":
               return "等待买家确认收货";
           case "120":
               return "交易完成";
           case "200":
               return "已取消";
           case "310":
           case "320":
               return "已退货";
           default:
               switch (Integer.parseInt(String.valueOf(orderState.charAt(2)))){
                   case 2:
                       return "退货处理中";
                   default:
                       return "系统处理中";
               }

       }
    }


    public List<ApiOrderGoodsResp> getOrderGoodsList() {
        return orderGoodsList;
    }

    public void setOrderGoodsList(List<ApiOrderGoodsResp> orderGoodsList) {
        this.orderGoodsList = orderGoodsList;
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getOrderState() {
        return orderState;
    }

    public void setOrderState(String orderState) {
        this.orderState = orderState;
    }

    public String getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(String orderNumber) {
        this.orderNumber = orderNumber;
    }

    public String getOrderPrice() {
        return orderPrice;
    }

    public void setOrderPrice(String orderPrice) {
        this.orderPrice = orderPrice;
    }

    public String getOrderFreight() {
        return orderFreight;
    }

    public void setOrderFreight(String orderFreight) {
        this.orderFreight = orderFreight;
    }

    public String getExpressCompany() {
        return expressCompany;
    }

    public void setExpressCompany(String expressCompany) {
        this.expressCompany = expressCompany;
    }

    public String getExpressNumber() {
        return expressNumber;
    }

    public void setExpressNumber(String expressNumber) {
        this.expressNumber = expressNumber;
    }

    public ApiOrderAddressResp getShippingAddress() {
        return shippingAddress;
    }

    public void setShippingAddress(ApiOrderAddressResp shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }
}
